package modelLayer;
import java.util.ArrayList;


/**
 * Write a description of class DvdContainer here.
 * 
 * @author group 5 
 * @version 2014-11-04
 */
public class DvdContainer{
    private static DvdContainer instance;
    private static ArrayList <DVD> myDvdContainer;
    
    private DvdContainer() {
        myDvdContainer= new ArrayList <DVD> ();
    }
    
    public static DvdContainer getInstance(){
        if(instance == null){
            instance= new DvdContainer();
        }
        return instance;
    }
    
    
    public boolean isNotEmptyDVD(){
        return myDvdContainer != null;
    }
    
    public void deleteDVD(DVD dv1){
        if(findDvdByBarcode(dv1.getBarcode())!=null)
        myDvdContainer.remove(dv1);
        else
        System.out.println("I can't find this Dvd");
    }
    
    public void addDVD(DVD dv2) {
        myDvdContainer.add(dv2);
    }
    
    public DVD findDvdByBarcode(int barcode){
        if(isNotEmptyDVD()){
            boolean found= false;
            int index=0;
            while(!found&& index < myDvdContainer.size()) {
                if(myDvdContainer.get(index).getBarcode()==barcode){
                    found=true;
                    return myDvdContainer.get(index);
                }
            index++;}
        }
        return null;}
        
    public void printAllDvds(){
        if(myDvdContainer.size()!=0)
        {
        for(int i=0; i<myDvdContainer.size(); i++){
            myDvdContainer.get(i).showDvd();
        }
    }
    else
    System.out.println("You don't have any dvds");
    }
    
  /*  public void printEverything(){
        for(int i=0; i < myDvdContainer.size(); i++) {
            myDvdContainer.get(i).showDvd();
            myDvdContainer.get(i).ShowCopysInfo();
        }
}*/}